﻿using System;

namespace Program23
{
    class Program
    {

        /// <summary>
        /// 选择排序法
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {

            int[] arr = new int[] { 9, 8, 10,3,26, 12, 5 };
            int min = arr[0];
            int temp = 0;
            int pos = 0;
            for (int i = 0; i < arr.Length - 1; i++)
            {
                min = arr[i + 1];
                for (int x = i; x < arr.Length; x++)
                {

                    if (min > arr[x]) 
                    {
                        min = arr[x];
                        pos = x;
                    }
                }
                temp = arr[i];
                arr[i] = min;
                arr[pos] = temp;              
            }
            foreach (var item in arr)
            {
                Console.WriteLine(item);
            }
        }
    }
}
